package com.gcd.alienandwheel.actor;

import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

/**
 *
 * @author Rezan Achmad
 */
public class Tiled extends MyActor {

    protected int numberX;
    protected int numberY;

    public Tiled(String name, FileHandle file, int numberX, int numberY) {
        super(name);
        setTexture(file);
        this.numberX = numberX;
        this.numberY = numberY;
    }

    public Tiled(String name, FileHandle file, float screenWidth, float screenHeight) {
        super(name);
        setTexture(file);
        numberX = (int) (Math.ceil(screenWidth / texture.getWidth()));
        numberY = (int) (Math.ceil(screenHeight / texture.getHeight()));
    }

    @Override
    protected void draw(SpriteBatch batch, float parentAlpha) {
        for (int i=0; i <numberX; ++i) {
            for (int j=0; j < numberY; ++j) {
                batch.draw(texture, texture.getWidth() * i, texture.getHeight() * j);
            }
        }
    }
}
